package com.culture.config.controller;

import java.util.List;

import javax.validation.Valid;

import com.culture.config.common.model.ResponseData;
import com.culture.config.common.util.ResponseUtil;
import com.culture.config.model.po.LogPageParam;
import com.culture.config.model.vo.LogVO;
import com.culture.config.service.EventLogService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@Api
@RestController
@RequestMapping("/api/log")
public class LogController extends BaseController{
    @Autowired
    private EventLogService eventLogService;
    
    @ApiOperation("page log")
	@PreAuthorize(value = "hasRole('ROLE_admin')")
	@PostMapping("/page")
    public ResponseData<List<LogVO>> page(@RequestBody @Valid LogPageParam param){
        this.authenticationValidate();
        return ResponseUtil.successPage(this.eventLogService.page(param));
    }
}
